package departure;

import common.ImagePanel;
import java.awt.Dimension;

/**
 *
 * @author Casper, Dennis, Jackie, Jakob
 * @version 1.00
 */
public class InvoiceForm extends javax.swing.JDialog {

    private Bill bill;

    /**
     *
     * @param parent
     * @param modal
     */
    public InvoiceForm(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        this.setPreferredSize(new Dimension(800, 600));
        initComponents();
    }

    /**
     *
     * @param bill
     */
    public void start(Bill bill) {
        this.bill = bill;
        setInfoLbl();
        setVisible(true);
    }

    /**
     *
     */
    private void setInfoLbl() {
        customerLbl.setText(bill.drawGuestinfo());
        payLbl.setText(bill.getPayMethod());
        line1.setText(bill.getAdditionalLine(0));
        line2.setText(bill.getAdditionalLine(1));
        line3.setText(bill.getAdditionalLine(2));
        price1.setText(bill.getAdditionalPrice(0));
        price2.setText(bill.getAdditionalPrice(1));
        String price = bill.getAdditionalPrice(2);
        if(price.equalsIgnoreCase("0")){
            price3.setText("");
        }
        else {
            price3.setText(price);
        }
        dayCount.setText(bill.getDayCount()+"");
        ppd.setText(bill.calcEndPayment()/bill.getDayCount()+"");
        endPriceLbl.setText(bill.calcEndPayment()+"");
        roomNoLbl.setText(bill.getRoomNo());
        period.setText(bill.getPeriod());

        setTitle("Hotel Lazy BMS - Invoice no: "+bill.getBillNo());
        setVisible(true);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        drawpnl = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        customerLbl = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        payLbl = new javax.swing.JLabel();
        line1 = new javax.swing.JLabel();
        price1 = new javax.swing.JLabel();
        line2 = new javax.swing.JLabel();
        price2 = new javax.swing.JLabel();
        line3 = new javax.swing.JLabel();
        price3 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        endPriceLbl = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        roomNoLbl = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        period = new javax.swing.JLabel();
        ppd = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        dayCount = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Hotel Lazy BMS - Invoice");

        drawpnl.setBackground(new java.awt.Color(255, 255, 255));

        jLabel1.setText("Customer :");

        customerLbl.setText("name info label");

        jLabel6.setText("Pays with:");

        payLbl.setText("jLabel7");

        line1.setText("product line 1");

        price1.setText("line 1 price");

        line2.setText("Product line 2");

        price2.setText("line 2 price");

        line3.setText("Product line 3");

        price3.setText("Line 3 price");

        jLabel14.setText("To pay");

        endPriceLbl.setText("endPrice");

        jLabel2.setText("Room Number :");

        roomNoLbl.setText("jLabel3");

        jLabel3.setText("Booking period :");

        period.setText("jLabel4");

        ppd.setText("jLabel7");

        jLabel7.setText("Price per day");

        jLabel8.setText("Full days ");

        dayCount.setText("jLabel9");

        jButton1.setText("Close Invoice");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText("INVOICE");

        jPanel3.setMinimumSize(new java.awt.Dimension(100, 50));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 50, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout drawpnlLayout = new javax.swing.GroupLayout(drawpnl);
        drawpnl.setLayout(drawpnlLayout);
        drawpnlLayout.setHorizontalGroup(
            drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, drawpnlLayout.createSequentialGroup()
                .addContainerGap(556, Short.MAX_VALUE)
                .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(dayCount)
                    .addComponent(endPriceLbl)
                    .addComponent(ppd)
                    .addComponent(price3)
                    .addComponent(price2)
                    .addComponent(price1))
                .addGap(106, 106, 106))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, drawpnlLayout.createSequentialGroup()
                .addContainerGap(628, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addContainerGap())
            .addGroup(drawpnlLayout.createSequentialGroup()
                .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(drawpnlLayout.createSequentialGroup()
                        .addGap(41, 41, 41)
                        .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel1)
                            .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel2)
                                .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(line1)
                                    .addComponent(jLabel3)
                                    .addComponent(line2)
                                    .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(line3)
                                        .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel8)
                                            .addComponent(jLabel7)
                                            .addComponent(jLabel14))))))
                        .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(drawpnlLayout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(payLbl)
                                    .addComponent(customerLbl)))
                            .addGroup(drawpnlLayout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(period)
                                    .addComponent(roomNoLbl)))))
                    .addGroup(drawpnlLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 599, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        drawpnlLayout.setVerticalGroup(
            drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(drawpnlLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(drawpnlLayout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(customerLbl))
                        .addGap(31, 31, 31)
                        .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(payLbl))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(roomNoLbl))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(period)))
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(32, 32, 32)
                .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(price1)
                    .addComponent(line1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(price2)
                    .addComponent(line2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(price3)
                    .addComponent(line3))
                .addGap(29, 29, 29)
                .addGroup(drawpnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(drawpnlLayout.createSequentialGroup()
                        .addComponent(ppd)
                        .addGap(4, 4, 4)
                        .addComponent(dayCount)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(endPriceLbl)
                        .addGap(18, 18, 18)
                        .addComponent(jButton1))
                    .addGroup(drawpnlLayout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addGap(4, 4, 4)
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel14)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.add(new ImagePanel("logo.png"));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(drawpnl, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(drawpnl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        close();
    }//GEN-LAST:event_jButton1ActionPerformed

    public void close(){
        setVisible(false);
    }

    /**
     *
     * @param args
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                InvoiceForm dialog = new InvoiceForm(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel customerLbl;
    private javax.swing.JLabel dayCount;
    private javax.swing.JPanel drawpnl;
    private javax.swing.JLabel endPriceLbl;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JLabel line1;
    private javax.swing.JLabel line2;
    private javax.swing.JLabel line3;
    private javax.swing.JLabel payLbl;
    private javax.swing.JLabel period;
    private javax.swing.JLabel ppd;
    private javax.swing.JLabel price1;
    private javax.swing.JLabel price2;
    private javax.swing.JLabel price3;
    private javax.swing.JLabel roomNoLbl;
    // End of variables declaration//GEN-END:variables
}
